//
//  TableViewControllerBase.m
//  MKUITestApp
//
//  Created by 苏尚进 on 2020/8/24.
//  Copyright © 2020 moon. All rights reserved.
//

#import "TableViewControllerBase.h"
#import "EmptyDataView.h"
@interface TableViewControllerBase ()

@end

@implementation TableViewControllerBase
+ (MKTFuncItem *)funcItem{
    return [MKTFuncItem funcWithName:NSStringFromClass(self) viewControllerClass:self];
}
- (id)init{
    if(self=[super initWithStyle:([self.class tableViewStyle])]){
        self.tabBarItem.title = [self.class funcItem].name;
        self.title = [self.class funcItem].name;
    }
    return self;
}
+ (UITableViewStyle)tableViewStyle{
    UITableViewStyle style = UITableViewStylePlain;
    if (@available(iOS 13.0, *)) {
        style = UITableViewStyleInsetGrouped;
    }
    return style;
}
- (CGRect)safeBounds{
    CGRect fullBounds = self.view.bounds;
    CGRect bounds = fullBounds;
    if (@available(iOS 11.0, *)) {
        bounds = self.view.safeAreaLayoutGuide.layoutFrame;
    } else {
    }
    return bounds;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.model = [[MKUITableViewModel alloc] init];
    self.model.hiddenSectionHeadView = self.class.hiddenSectionHeadFootView;
    self.model.hiddenSectionFootView = self.class.hiddenSectionHeadFootView;
    [self.model setTableViewDataSourceAndDelegate:self.tableView];
    self.model.emptyBackgroundViewClass = [EmptyDataView class];
    [self.tableView mk_hiddenFooterAreaSeparators];
    NSLog(@"viewDidLoad:%@",NSStringFromClass(self.class));
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self.model deselectAllCellModelsWithAnimated:YES];
    NSLog(@"viewDidAppear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
+ (BOOL)hiddenSectionHeadFootView{
    return NO;;
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    NSLog(@"viewWillDisappear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    NSLog(@"viewDidDisappear:%@,animated:%@",NSStringFromClass(self.class),@(animated));
}
@end
